package com.tedu.micro.service.controller;

import com.tarena.micro.service.common.result.JsonResult;
import com.tarena.micro.service.pojo.param.CartAddParam;
import com.tedu.micro.service.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理所有和购物车相关的业务接口
 */
//组合注解 = @Controller @ResponseBody
@RestController
public class CartController {
    @Autowired
    private CartService cartService;
    //新增购物车
    @PostMapping("/cart/add")
    public JsonResult addCart(CartAddParam param) {
        //调用业务层
        System.out.println("接到参数:"+param);
        cartService.addCart(param);
        //使用JsonResult 不需要携带查询数据返回 直接返回
        return JsonResult.ok();//和前端约定好的结果 {"state":200,"message":"ok","data":null}
    }
}
